<%@ page import="id.co.gomobile.assessment.Item" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>Item Details</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>Item Details</h1>

    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>

    <div class="dialog">

    <fieldset>
 
    <h3>Item Details</h3>
            
    <div class="dialog">
        <table>
        <col width="200px" />
        <tbody>
            <tr class="prop">
	            <td valign="top" class="name"><g:message code="item.id.label" default="Id" /></td>
	            <td valign="top" class="value">${fieldValue(bean: itemInstance, field: "id")}</td>
            </tr>

            <tr class="prop">
                <td valign="top" class="name"><g:message code="item.test.label" default="Test" /></td>
                <td valign="top" class="value"><g:link controller="test" action="show" id="${itemInstance?.test?.id}" class="reference">${fieldValue(bean: itemInstance, field: "test.name")}</g:link></td>
            </tr>

            <tr class="prop">
	           <td valign="top" class="name"><g:message code="item.text.label" default="Text" /></td>
	           <td valign="top" class="value">${itemInstance?.text}</td>
	        </tr>
                    
            <tr class="prop">
                <td valign="top" class="name"><g:message code="item.category.label" default="Category" /></td>
                <td valign="top" class="value">${fieldValue(bean: itemInstance, field: "category")}</td>
            </tr>
                    
            <tr class="prop">
                <td valign="top" class="name"><g:message code="item.type.label" default="Type" /></td>
                <td valign="top" class="value">${itemInstance.type()}</td>
            </tr>

            </tbody>
        </table>
    </div>
    
    <br/>

     <div class="buttons">
        <g:form>
            <g:hiddenField name="id" value="${itemInstance?.id}" />
            <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
            <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
        </g:form>
     </div>
        
    </fieldset>

    <br/>

    <fieldset>
    
    <h3>List of Options</h3>
    
    <div class="list">
    <table>
        <col width="50" />
        <col />
        <col width="150" />
        <col width="150" />
        <thead>
            <tr>
                <th colspan="4" align="right">${itemOptionList.size()} displayed</th>
            </tr>
            <tr>
                <g:sortableColumn property="id" title="${message(code: 'itemOption.id.label', default: 'Id')}" />
                <g:sortableColumn property="text" title="${message(code: 'itemOption.text.label', default: 'Text')}" />
                <g:sortableColumn property="correct" title="${message(code: 'itemOption.correct.label', default: 'Is Correct?')}" />
                <th title="Action">Action</th>
            </tr>
        </thead>
        <tbody>
        <g:each in="${itemOptionList}" status="i" var="itemOptionInstance">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td>${fieldValue(bean: itemOptionInstance, field: "id")}</td>
                <td>${fieldValue(bean: itemOptionInstance, field: "text")}</td>
                <td><g:formatBoolean boolean="${itemOptionInstance?.correct}" true="Yes" false="No" /></td>
                <td style="text-align: center">
                    <g:form controller="itemOption" action="edit" id="${itemOptionInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_edit.png')}" alt="Edit" />
                    </g:form>
                    &nbsp;
                    <g:form controller="itemOption" action="delete" id="${itemOptionInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_delete.png')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" alt="Delete" />
                    </g:form>
                </td>
            </tr>
        </g:each>
        </tbody>
    </table>
    </div>

    <br/>
    
    <div class="buttons">
        <g:form controller="itemOption">
            <g:hiddenField name="item.id" value="${itemInstance?.id}" />
            <span class="button"><g:actionSubmit class="create" action="create" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
        </g:form>
    </div>

    </fieldset>

    </div>
    
    </div>
    </body>
</html>